#include "fxcc/core/graph/common/Maps.h"
#include "fxcc/core/graph/common/ModelLoader.h"
#include "fxcc/core/graph/common/TextureLoader.h"
#include "fxcc/core/graph/common/ShaderLoader.h"

bool fxcc::graph::common::BRDFTextureMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadBrdfMap(m_Index.m_TargetFilePath);
    ztclog::info("brdf Path is %s", m_Index.m_TargetFilePath.c_str());
    return true;
}

bool fxcc::graph::common::IrradianceTextureMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadIrradianceMap(m_Index.m_TargetFilePath);
    ztclog::info("Irradiance Map Path is %s", m_Index.m_TargetFilePath.c_str());
    return true;
}

bool fxcc::graph::common::PrefilterTextureMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadPrefilterMap(m_Index.m_TargetFilePath);
    ztclog::info("Prefilter Path is %s", m_Index.m_TargetFilePath.c_str());
    return true;
};

bool fxcc::graph::common::Texture2DMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.Load2DFile(m_Index.m_TargetFilePath);
    ztclog::info("Path is %s", m_Index.m_TargetFilePath.c_str());
    return true;
}

bool fxcc::graph::common::TextureCubeMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadDDSCubeFile(m_Index.m_TargetFilePath);
    return true;
}

bool fxcc::graph::common::Texture2DArrayMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadDDS2DArrayFile(m_Index.m_TargetFilePath);
    return true;
}

bool fxcc::graph::common::TextureCubeArrayMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadDDSCubeArrayFile(m_Index.m_TargetFilePath);
    return true;
}

bool fxcc::graph::common::Texture3DMap::OnLoad()
{
    TextureLoader loader;
    m_Value = loader.LoadDDS3DFile(m_Index.m_TargetFilePath);
    return true;
}

bool fxcc::graph::common::MeshMap::OnLoad()
{
    ztclog::debug("Mesh map on Load");
    ModelLoader m_ModelLoader;
    m_Value = m_ModelLoader.LoadMeshFile(m_Index.m_TargetFilePath);
    return m_Value.get();
}

bool fxcc::graph::common::SkinnedMeshMap::OnLoad()
{
    ztclog::info("Skinned Mesh map on Load");
    ModelLoader m_ModelLoader;
    m_Value = m_ModelLoader.LoadSkinnedFile(m_Index.m_TargetFilePath);
    return m_Value.get();
}

bool fxcc::graph::common::BoneFileMap::OnLoad()
{
    ztclog::debug("bones on Load");
    ModelLoader m_ModelLoader;
    m_Value = m_ModelLoader.LoadBones(m_Index.m_TargetFilePath);
    return m_Value.get();
}

bool fxcc::graph::common::MaterialViewMap::OnLoad()
{
    ztclog::debug("material data OnLoad");
    ModelLoader m_ModelLoader;
    m_Value = m_ModelLoader.LoadMaterial(m_Index.m_TargetFilePath);
    
    if (m_Value)
    {
        m_Value->OnLoad();
    }
    return m_Value.get();
}

